<template>
  <div class="app-container">
    {% set queryTypeDict={"EQ":"等于",
"NE":"不等于",
"GT":"大于",
"GTE":"大于或等于",
"LT":"小于",
"LTE":"小于或等于",
"LIKE":"包含",
"START":"开始于",
"BETWEEN":"之间"} %}

    <el-form :model="queryParams" ref="queryRef" class="queryForm" v-show="showSearch">
      <el-row :gutter="15">
        {% for column in columns %}
          {% if column.isQuery %}
            <el-col :span="24" :md="12" :lg="8" :xl="6">
              {% if column.htmlType == "input" or column.htmlType == "textarea" %}
                <el-form-item label="${{ column.comment }}" prop="${{ column.javaField }}">
                  <el-input
                      v-model="queryParams.${{ column.javaField }}"
                      placeholder="请输入${{ column.comment }}（${{ queryTypeDict[column.queryType] }}）"
                      clearable
                      @keyup.enter.native="handleQuery"
                  />
                </el-form-item>
              {% elif column.htmlType == "select"  or  column.htmlType == "radio" %}
                {% if column.dictType %}
                  <el-form-item label="${{ column.comment }}" prop="${{ column.javaField }}">
                    <el-select v-model="queryParams.${{ column.javaField }}" placeholder="请选择${{ column.comment }}"
                               clearable>
                      <el-option v-for="dict in ${{ column.dictType }}" :key="dict.value" :label="dict.label"
                                 :value="dict.value"/>
                    </el-select>
                  </el-form-item>
                {% elif column.hasFk %}
                  <el-form-item label="${{ column.comment }}" prop="${{ column.javaField }}">
                    <el-select v-model="queryParams.${{ column.javaField }}" placeholder="请选择${{ column.comment }}"
                               clearable>
                      <el-option
                          v-for="(item,key) in ${{ column.javaField }}Map"
                          :key="key"
                          :label="item"
                          {% if column.javaType == "Integer"  or  column.javaType == "Long" %}:value="parseInt(key)"
                          {% else %} :value="key"{% endif %}
                      />
                    </el-select>
                  </el-form-item>
                {% else %}
                  <el-form-item label="${{ column.comment }}" prop="${{ column.javaField }}">
                    <el-select v-model="queryParams.${{ column.javaField }}" placeholder="请选择${{ column.comment }}"
                               clearable>
                      <el-option label="请选择字典生成" value=""/>
                    </el-select>
                  </el-form-item>
                {% endif %}
              {% elif column.htmlType == "datetime" or column.htmlType == "date" %}
                {% if column.queryType =="BETWEEN" %}
                  <div class="d-flex">
                    <el-form-item label="${{ column.comment }}" prop="begin${{ column.javaFieldCap }}">
                      <el-date-picker
                          v-model="queryParams.params.begin${{ column.javaFieldCap }}" value-format="YYYY-MM-DD"f
                          type="date"
                          title="请选择${{ column.comment }}开始日期"
                          clearable
                          @keyup.enter.native="handleQuery" style="width:unset;"
                      />
                    </el-form-item>
                    <span style="margin:5px">至</span>
                    <el-form-item props="end${{ column.javaFieldCap }}">
                      <el-date-picker v-model="queryParams.params.end${{ column.javaFieldCap }}"
                                      title="请选择${{ column.comment }}结束日期" value-format="YYYY-MM-DD"
                                      type="date"
                                      clearable @keyup.enter.native="handleQuery" style="width:unset;"/>
                    </el-form-item>
                  </div>
                {% else %}
                  <el-form-item label="${{ column.comment }}" prop="${{ column.javaField }}">
                    <el-date-picker clearable
                                    v-model="queryParams.${{ column.javaField }}"
                                    type="${{column.htmlType}}"
                                    value-format="YYYY-MM-DD{% if column.htmlType == "datetime" %} HH:mm:ss{% endif %}"
                                    placeholder="选择${{ column.comment }}（${{ queryTypeDict[column.queryType] }}）">
                    </el-date-picker>
                  </el-form-item>
                {% endif %}
              {% elif column.htmlType == "number" %}
                {% if column.queryType =="BETWEEN" %}
                  <div class="d-flex">
                    <el-form-item label="${{ column.comment }}区间" prop="begin${{ column.javaFieldCap }}">
                      <el-input
                          v-model="queryParams.params.begin${{ column.javaFieldCap }}"
                          title="请输入${{ column.comment }}最小值"
                          clearable
                          @keyup.enter.native="handleQuery"
                      />
                    </el-form-item>
                    <span style="margin:5px">至</span>
                    <el-form-item props="end${{ column.javaFieldCap }}">
                      <el-input v-model="queryParams.params.end${{ column.javaFieldCap }}"
                                title="请输入${{ column.comment }}最大值"
                                clearable @keyup.enter.native="handleQuery"/>
                    </el-form-item>
                  </div>
                {% else %}
                  <el-form-item label="${{ column.comment }}" prop="${{ column.javaField }}">
                    <el-input
                        v-model="queryParams.${{ column.javaField }}"
                        placeholder="请输入${{ column.comment }}（${{ queryTypeDict[column.queryType] }}）"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                {% endif %}
              {% endif %}
            </el-col>
          {% endif %}
        {% endfor %}
        <el-col :span="24" :md="12" :lg="8" :xl="6">
          <el-form-item>
            <el-button type="primary" icon="Search" @click="handleQuery">查询</el-button>
            <el-button icon="Refresh" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>


    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
            type="primary"
            plain
            icon="Plus"
            @click="handleAdd"
            v-hasPermi="['${{ permissionPrefix }}:add']"
        >新增
        </el-button>
      </el-col>
      {#      <el-col :span="1.5">#}
      {#        <el-button#}
      {#            ## type="success"#}
      {#            ## plain#}
      {#            ## icon="Edit"#}
      {#            ## :disabled="single"#}
      {#            ## @click="handleUpdate"#}
      {#            ## v-hasPermi="['${{ permissionPrefix }}:edit']"#}
      {#            ##>修改#}
      {#        </el-button>#}
      {#        ###}
      {#      </el-col>#}
      <el-col :span="1.5">
        <el-button
            type="danger"
            plain
            icon="Delete"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['${{ permissionPrefix }}:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="warning"
            plain
            icon="Download"
            @click="handleExport"
            v-hasPermi="['${{ permissionPrefix }}:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
{% macro tableColumnAttrs(column) -%}
label="${{ column.comment }}" {% if column.sortable %} sortable="custom" {% endif %} align="center" prop="${{ column.javaField }}"
{%- endmacro %}
    <el-table v-loading="loading"{% if fixedHeader %} v-fixedTableHeight="85"{% endif %}
              :data="${{ businessName }}List" @selection-change="handleSelectionChange"
        {% if hasSortColumn %}  @sort-change="sortChange"{% endif %}>
      <el-table-column type="selection" width="55" align="center"/>
      {% for column in columns %}
        {% if column.isList %}
          {% if column.htmlType == "datetime" or column.htmlType == "date" %}
            <el-table-column ${{tableColumnAttrs(column)}}/>
          {% elif column.dictType %}
            <el-table-column ${{tableColumnAttrs(column)}}>
              <template #default="{row}">
                <dict-tag :options="${{ column.dictType }}" :value="row.${{ column.javaField }}"/>
              </template>
            </el-table-column>
          {% elif column.htmlType == "select"  and  column.hasFk %}
            <el-table-column  ${{tableColumnAttrs(column)}} :formatter="${{ column.javaField }}Format"/>
           {% elif column.htmlType == "imageUpload"%}
             <el-table-column  ${{tableColumnAttrs(column)}}>
              <template #default="{row}">
                       <el-image preview-teleported
                                 src="/images/preview.svg"
                                 style="width: 20px;height: 20px;cursor: pointer"
                                 :preview-src-list="row.${{ column.javaField }}.map(url=>baseUrl+url)"
                                 v-if="row.${{ column.javaField }}&&row.${{ column.javaField }}.length>0"
                                 lazy
                       />

                     </template>
             </el-table-column>
           {% elif column.javaType == "String" %}
           <el-table-column  ${{tableColumnAttrs(column)}}
                             {% if column.maxLength>200 or column.maxLength==0  %}show-overflow-tooltip{% endif %}/>
          {% elif column.javaField %}
            <el-table-column  ${{tableColumnAttrs(column)}}/>
          {% endif %}
        {% endif %}
      {% endfor %}
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="{row}">
          <el-button type="primary" text icon="Edit" @click="handleUpdate(row)"
                     v-hasPermi="['${{ permissionPrefix }}:edit']">修改
          </el-button>
          <el-button type="danger" text icon="Delete" @click="handleDelete(row)"
                     v-hasPermi="['${{ permissionPrefix }}:remove']">删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total>0" :total="total" v-model:page="queryParams.pageNum"
                v-model:limit="queryParams.pageSize" @pagination="getList"/>
    <!-- 添加或修改${{functionName}}对话框 -->
    <el-dialog :title="title" v-model="open" {% if insertEditCnt>=8 %}width="650px"{% else %}
               width="500px"{% endif %}>
     {% if insertEditCnt>=12 %} <el-scrollbar height="600px" class="pr-2" > {% endif %}
      <el-form ref="${{ businessName }}Ref" :model="form" :rules="rules"  {% if insertEditCnt>=12 %} class="mr-2"  {% endif %}>
        {% if insertEditCnt>=8 %}
          <el-row :gutter="15">
        {% endif %}
        {% for column in columns %}
          {% if not column.special and not column.isPk and (column.isEdit or column.isInsert) %}

          {% if not column.isEdit and column.isInsert %} {% set disabled=":disabled='isEdit'" %}{%else%} {% set disabled="" %}{% endif %}
          <{% if insertEditCnt>=8 %}el-col {% if column.htmlType == "textarea" or column.htmlType == "imageUpload" or column.htmlType == "fileUpload" %}:span="24"{% else %}
                                                 :span="12"{% endif %}{% endif %} {% if column.isEdit and not column.isInsert %} v-show="isEdit"{% endif %}>
            <el-form-item label="${{ column.comment }}" prop="${{ column.javaField }}">
              {% if column.htmlType == "input" %}
                <el-input v-model="form.${{ column.javaField }}"  ${{disabled}} placeholder="请输入${{ column.comment }}"
                          {% if column.maxLength>0 %}:maxlength="${{ column.maxLength }}" show-word-limit{% endif %}/>
              {% elif column.htmlType == "imageUpload" %}
                <imageUpload v-model="form.${{ column.javaField }}"  ${{disabled}}/>
              {% elif column.htmlType == "fileUpload" %}
                <fileUpload v-model="form.${{ column.javaField }}"  ${{disabled}}/>
              {% elif column.htmlType == "editor" %}
                <editor v-model="form.${{ column.javaField }}" :min-height="192"  ${{disabled}}/>
              {% elif column.htmlType == "select" %}
                {% if column.dictType %}
                  <el-select v-model="form.${{ column.javaField }}"  ${{disabled}} placeholder="请选择${{ column.comment }}">
                    <el-option
                        v-for="dict in ${{ column.dictType }}"
                        :key="dict.value"
                        :label="dict.label"
                        {% if column.javaType == "Integer"  or  column.javaType == "Long" %}
                        :value="parseInt(dict.value)"
                        {% else %} :value="dict.value"{% endif %}
                    ></el-option>
                  </el-select>
                {% elif column.hasFk %}
                  <el-select v-model="form.${{ column.javaField }}" placeholder="请选择${{ column.comment }}" clearable>
                    <el-option
                        v-for="(item,key) in ${{ column.javaField }}Map"
                        :key="key"
                        :label="item"
                        {% if column.javaType == "Integer"  or  column.javaType == "Long" %}:value="parseInt(key)"
                        {% else %} :value="key"{% endif %}
                    />
                  </el-select>
                {% else %}
                  <el-select v-model="form.${{ column.javaField }}"  ${{disabled}} placeholder="请选择${{ column.comment }}">
                    <el-option label="请选择字典生成" value=""/>
                  </el-select>
                {% endif %}
              {% elif column.htmlType == "checkbox"  and  "" != column.dictType %}
                {% if column.dictType %}
                  <el-checkbox-group v-model="form.${{ column.javaField }}"  ${{disabled}}>
                    <el-checkbox
                        v-for="dict in ${{ column.dictType }}"
                        :key="dict.value"
                        :label="dict.value">
                      {{ dict.label }}
                    </el-checkbox>
                  </el-checkbox-group>
                {% else %}
                  <el-checkbox-group v-model="form.${{ column.javaField }}"  ${{disabled}}>
                    <el-checkbox>请选择字典生成</el-checkbox>
                  </el-checkbox-group>
                {% endif %}
              {% elif column.htmlType == "radio" %}
                {% if column.dictType %}
                  <el-radio-group v-model="form.${{ column.javaField }}"  ${{disabled}}>
                    <el-radio-button v-for="dict in ${{ column.dictType }}" :key="dict.value"
                                     {% if column.javaType == "Integer"  or  column.javaType == "Long" %}:value="parseInt(dict.value)"{% else %}
                                     :value="dict.value"{% endif %}
                    >{{ dict.label }}
                    </el-radio-button>
                  </el-radio-group>
                {% else %}
                  <el-radio-group v-model="form.${{ column.javaField }}"  ${{disabled}}>
                    <el-radio-button value="1">请选择字典生成</el-radio-button>
                  </el-radio-group>
                {% endif %}
              {% elif column.htmlType == "datetime" or column.htmlType == "date" %}
                <el-date-picker clearable
                                v-model="form.${{ column.javaField }}"  ${{disabled}}
                                type="${{column.htmlType}}"
                                value-format="YYYY-MM-DD{% if column.htmlType == "datetime" %} HH:mm:ss{% endif %}"
                                placeholder="选择${{ column.comment }}">
                </el-date-picker>
              {% elif column.htmlType == "time" %}
                <el-time-picker arrow-control clearable v-model="form.${{ column.javaField }}"  ${{disabled}} value-format="HH:mm:ss"
                                placeholder="选择${{ column.comment }}">
                </el-time-picker>
              {% elif column.htmlType == "textarea" %}
                <el-input v-model="form.${{ column.javaField }}"  ${{disabled}} type="textarea" autosize
                          placeholder="请输入${{ column.comment }}"
                          {% if column.maxLength>0 %}:maxlength="${{ column.maxLength }}" show-word-limit{% endif %}/>
              {% elif column.htmlType == "number" %}
                <el-input-number v-model="form.${{ column.javaField }}"  ${{disabled}} placeholder="输入${{ column.comment }}"
                                 :min="${{column.min}}"
                                 :max="{% if column.javaType== "BigDecimal" %}column.maxBigDecimal{% else %} ${{column.max}} {% endif %}"
                                 title="输入最大值为{% if column.javaType== "BigDecimal" %} column.maxBigDecimal{% else %}  ${{column.max}} {% endif %}"
                                 {% if column.precision>0 %}:precision="${{column.precision}}"{% endif %}
                                 controls-position="right"/>
              {% endif %}
            </el-form-item>
            {% if insertEditCnt>=8 %}</el-col>{% endif %}
        {% endif %}
        {% endfor %}
        {% if sub %}
          <el-divider content-position="center">${{ subTable.functionName }}信息</el-divider>
          <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
              <el-button type="primary" icon="Plus" size="small" @click="handleAdd${subClassName}">添加
              </el-button>
            </el-col>
            <el-col :span="1.5">
              <el-button type="danger" icon="Delete" size="small" @click="handleDelete${subClassName}">删除
              </el-button>
            </el-col>
          </el-row>
          <el-table :data="${{ subClassName }}List" :row-class-name="row${subClassName}Index"
                    @selection-change="handle${subClassName}SelectionChange" ref="${{ subClassName }}">
            <el-table-column type="selection" width="50" align="center"/>
            <el-table-column label="序号" align="center" prop="index" width="50"/>
            {% for column in subTable.columns %}
              {% if column.isPk  or  column.javaField  ==  subTableFkclassName %}
              {% elif column.list  and  "" != column.javaField %}
                <el-table-column label="${{ column.comment }}" prop="${{ column.javaField }}">
                  <template #default="{row}">
                    <el-input v-model="row.${{ column.javaField }}" placeholder="请输入${{ column.comment }}"/>
                  </template>
                </el-table-column>
              {% endif %}
            {% endfor %}
          </el-table>
        {% endif %}
        {% if insertEditCnt>=8 %}</el-row>{% endif %}
      </el-form>
      {% if insertEditCnt>=12 %} </el-scrollbar> {% endif %}
      <template #footer>
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="${{ businessName }}">
{% if hasImageInList %}
const baseUrl = import.meta.env.VITE_APP_BASE_API;
{% endif %}
    import {
        list${{BusinessName}},
        get${{BusinessName}},
        del${{BusinessName}},
        add${{BusinessName}},
        update${{BusinessName}}
    } from "@/api/${{moduleName}}/${{businessName}}";

    import {ElMessage, ElMessageBox} from "element-plus";
    {% if dicts!="" %}
        import {useDict} from "@/utils/dict.js";
        const { ${{dicts|replace("'","")}}} = useDict(${{dicts}});
    {% endif %}

    const ${{businessName}}List = ref([]);
    {% if sub %}
        const ${{subclassName}}List = ref([]);
    {% endif %}
    const open = ref(false);
    const loading = ref(true);
    const showSearch = ref(true);
    const ids = ref([]);
    {% if sub %}
        const checked${{subClassName}} = ref([]);
    {% endif %}
    const single = ref(true);
    const multiple = ref(true);
    const total = ref(0);
    const title = ref("");
    const queryParams = ref({
        pageNum: 1,
        pageSize: 10,
        {% if hasBetween %}
           params: {},
        {% endif %}

        {% for column in columns %}
            {% if column.query %}
                ${{ column.javaField}}: null,
            {% endif %}
        {% endfor %}
    });
    const rules = {
        {% for column in columns %}
            {% if not column.special and not column.isPk and (column.isEdit or column.isInsert) %}
                ${{ column.javaField}}: [
                    {% if column.isRequired %}
                        {
                            required: true,
                            message: "${{column.comment}}不能为空",
                            trigger: {% if column.htmlType == "select" %} "change" {% else %} "blur"{% endif %}
                        },
                    {% endif %}
                    {% if column.maxLength>0 and column.javaType=="String" and column.htmlType!="select" %}
                        {max: ${{ column.maxLength }}, message: '长度最长为 ${{ column.maxLength }} 个字符', trigger: 'change'},
                    {% endif %}
                    {% if column.more["pattern"] %}
                        {
                            pattern: /${{ column.more["pattern"] }}/,
                            message: "${{ column.more["patternMessage"]}}",
                            trigger: "change"
                        },
                    {% endif %}
                ],
            {% endif %}
        {% endfor %}
    }
    const form = ref({});
const isEdit=computed(()=>{
  return form.value.${{pkColumn.javaField}};
})
    /** 查询${{functionName}}列表 */
    function getList() {
        loading.value = true;
        {% if hasSortColumn %}
            delete queryParams.value.orderByColumn;
            delete queryParams.value.isAsc;

            // if (this.sortColumn) {
            //   const {prop, order} = this.sortColumn;
            //   if(prop and order){
            //     this.queryParams.orderByColumn = prop;
            //     this.queryParams.isAsc = order;
            //   }
            // }
        {% endif %}
        list${{BusinessName}}(queryParams.value).then(response => {
            ${{businessName}}List.value = response.rows;
            total.value = response.total;
            loading.value = false;
        });
    }

    // 取消按钮
    function cancel() {
        open.value = false;
        reset();
    }

    const ${{businessName}}Ref = ref();

    // 表单重置
    function reset() {
        form.value = {
            {% for column in columns %}

                {% if (tableOptions.softDelete and tableOptions.softDeleteColumn==column.columnName) or column.javaField=="createBy" or column.javaField=="createTime" or column.javaField== "updateBy" or column.javaField=="updateTime" %}
                {% elif column.defVal is not none %}
                    {% if column.javaType == "String" or column.javaType == "char" %}
                        ${{ column.javaField }}: "${{ column.defVal}}",
                    {% else %}
                        ${{ column.javaField }}: ${{ column.defVal}},
                    {% endif %}
                {% elif column.htmlType == "radio" %}
                    ${{ column.javaField }}: {% if column.javaType == "Boolean" %} 0, {% else %} "0", {% endif %}
                {% elif column.htmlType == "checkbox" %}
                    ${{ column.javaField }}: [],
                {% else %}
                    ${{ column.javaField }}: null,
                {% endif %}
            {% endfor %}
        };
        {% if sub %}
            ${{ subclassName}}List.value = [];
        {% endif %}
        ${{businessName}}Ref.value && ${{businessName}}Ref.value.resetFields();
    }

    /** 搜索按钮操作 */
    function handleQuery() {
        queryParams.value.pageNum = 1;
        getList();
    }

    const queryRef = ref();

    /** 重置按钮操作 */
    function resetQuery() {
        queryRef.value.resetFields();
        queryParams.value.params = {};
        handleQuery();
    }

    // 多选框选中数据
    function handleSelectionChange(selection) {
        ids.value = selection.map(item => item.${{pkColumn.javaField}});
        single.value = selection.length != 1;
        multiple.value = !selection.length;
    }

    /** 新增按钮操作 */
    function handleAdd() {
        reset();
        open.value = true;
        title.value = "添加${{functionName}}";
    }

    /** 修改按钮操作 */
    function handleUpdate(row) {
        reset();
        const _${{pkColumn.javaField}} = row.${{pkColumn.javaField}} || ids.value
        get${{BusinessName}}(_${{pkColumn.javaField}}).then(response => {
            form.value = response.data;
            {% for column in columns %}
                {% if column.htmlType == "checkbox" %}
                    form.value.${{ column.javaField }} = form.value.${{column.javaField}}.split(",");
                {% endif %}
            {% endfor %}
            {% if sub  %}
                ${{subclassName}}List.value = response.data.${{subclassName}}List;
            {% endif %}
            open.value = true;
            title.value = "修改${{functionName}}";
        });
    }

    /** 提交按钮 */
    function submitForm() {
        ${{businessName}}Ref.value.validate(valid => {
            if (valid) {
                {% for column in columns %}
                    {% if column.htmlType == "checkbox" %}
                        form.value.${{column.javaField}} = form.value.${{column.javaField}}.join(",");
                    {% endif %}
                {% endfor %}
                {% if sub %}
                    form.value.${{subclassName}}List = ${{subclassName}}List.value;
                {% endif %}
                if (form.value.${{pkColumn.javaField}} != null) {
                    update${{BusinessName}}(form.value).then(response => {
                        ElMessage.success("修改成功");
                        open.value = false;
                        getList();
                    });
                } else {
                    add${{BusinessName}}(form.value).then(response => {
                        ElMessage.success("新增成功");
                        open.value = false;
                        getList();
                    });
                }
            }
        });
    }

    /** 删除按钮操作 */
    function handleDelete(row) {
        const _${{pkColumn.javaField}}s = row.${{pkColumn.javaField}} || ids.value;
        ElMessageBox.confirm('是否确认删除${{functionName}}编号为"' + _${{pkColumn.javaField}}s + '"的数据项？').then(function () {
            return del${{BusinessName}}(_${{pkColumn.javaField}}s);
        }).then(() => {
            getList();
            ElMessage.success.success("删除成功");
        }).catch(() => {
        });
    }

    {% if sub %}
        /** ${{subTable.functionName}}序号 */
        function row${{subClassName|upper}}Index({row, rowIndex}) {
            row.index = rowIndex + 1;
        }

        /** ${{subTable.functionName}}添加按钮操作 */
        function handleAdd${{subClassName|upper}}() {
            let obj = {};
            {% for column in subTable.columns %}
                {% if column.pk  or  column.javaField == subTableFkclassName %}
                {% elif column.isList  and  "" != column.javaField %}
                    obj.${{column.javaField  }} = "";
                {% endif %}
            {% endfor %}
            ${{ subclassName }}List.value.push(obj);
        }

        /** ${{subTable.functionName}}删除按钮操作 */
        function handleDelete${{subClassName|upper}}() {
            if (checked${{subClassName|upper}}.value.length == 0) {
                ElMessage.error("请先选择要删除的${subTable.functionName}数据");
            } else {
                const ${{subClassName}}s = ${{subClassName}}List.value;
                const checked${{subClassName|upper}}s = checked${{subClassName|upper}}.value;
                ${{subClassName}}List.value = ${{subClassName}}s.filter(function (item) {
                    return checked${{subClassName|upper}}s.indexOf(item.index) == -1
                });
            }
        }

        /** 复选框选中数据 */
        function handle${{subClassName|upper}}SelectionChange(selection) {
            checked${{subClassName|upper}}.value = selection.map(item => item.index)
        }

    {% endif %}

    import {download} from "@/utils/request.js";

    /** 导出按钮操作 */
    function handleExport() {
        download('${{moduleName}}/${{businessName}}/export', {
            ...queryParams.value
        }, `${{businessName}}_${new Date().getTime()}.xlsx`)
    }

    getList();
</script>
